import {
  getCategoryGoodsAmount,
  getCategoryGoodsCount,
  getCategoryGoodsSale,
  getCategoryGoodsFavor,
  getCategoryAddressSale
} from '../../../service/mian/analysis/dashboared'
const dashboardModule = {
  namespaced: true,
  state() {
    return {
      categoryGoodsCount: [],
      categoryGoodsSale: [],
      categoryGoodsFavor: [],
      addressGoodsSale: [],
      addressGoodsAmount: []
    }
  },
  mutations: {
    categoryGoodsAmount(state, list) {
      state.addressGoodsAmount = list
    },
    changeCategoryGoodsCount(state, list) {
      state.categoryGoodsCount = list
    },
    changeCategoryGoodsSale(state, list) {
      state.categoryGoodsSale = list
    },
    changeCategoryGoodsFavor(state, list) {
      state.categoryGoodsFavor = list
    },
    changeAddressGoodsSale(state, list) {
      state.addressGoodsSale = list
    }
  },
  actions: {
    async getDashboardDataAction({ commit }) {
      const categoryGoodsAmount = await getCategoryGoodsAmount()
      const categoryGoodsCountResult = await getCategoryGoodsCount()
      const categoryGoodsSaleResult = await getCategoryGoodsSale()
      const categoryGoodsFavorResult = await getCategoryGoodsFavor()
      const categoryGoodsAddressResult = await getCategoryAddressSale()
      commit('categoryGoodsAmount', categoryGoodsAmount.data)
      commit('changeCategoryGoodsCount', categoryGoodsCountResult.data)
      commit('changeCategoryGoodsSale', categoryGoodsSaleResult.data)
      commit('changeCategoryGoodsFavor', categoryGoodsFavorResult.data)
      commit('changeAddressGoodsSale', categoryGoodsAddressResult.data)
    }
  }
}
export default dashboardModule
